﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using Maticsoft.BLL;
using Maticsoft.Model;

namespace FineUI.Examples
{
    public partial class admin_configuration_classes : System.Web.UI.Page
    {
        protected DataSet LoadTeachingClassInform()
        {
            Maticsoft.BLL.TeachingClass TeachingClass = new Maticsoft.BLL.TeachingClass();
            DataSet DSTeachingClass = TeachingClass.GetList("TeachingClass.T_id=Teacher.T_Id");
            for (int i = 0; i < DSTeachingClass.Tables[0].Rows.Count; i++)
            {
                DSTeachingClass.Tables[0].Rows[i]["TC_Date_Day"] = DSTeachingClass.Tables[0].Rows[i]["TC_Date_Day"] + "    第 " + DSTeachingClass.Tables[0].Rows[i]["TC_Date_Time"]+" 节课";
            }

            DataView view1 = DSTeachingClass.Tables[0].DefaultView;
            Grid1.DataSource = view1;
            Grid1.DataBind();
            return DSTeachingClass;


        }
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadTeachingClassInform();
        }

        
        protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "ActionDelete")
            {
                int key = e.RowIndex;
                DataSet currentDataSet= LoadTeachingClassInform();
                string current_TC_Id =currentDataSet.Tables[0].Rows[key]["TC_Id"].ToString();
                string current_C_Id=currentDataSet.Tables[0].Rows[key]["C_Id"].ToString();
                string current_T_Id=currentDataSet.Tables[0].Rows[key]["T_Id"].ToString();
                string current_CL_Id=currentDataSet.Tables[0].Rows[key]["CL_Id"].ToString();
              
                //删除教学班信息
                Maticsoft.BLL.TeachingClass TeachingClass = new Maticsoft.BLL.TeachingClass();

                TeachingClass.Delete(current_TC_Id, current_C_Id, current_T_Id, current_CL_Id);

                //删除选课信息


                Maticsoft.BLL.SelectCourse SelectCourse = new Maticsoft.BLL.SelectCourse();
                SelectCourse.DeleteChoseCourse(current_TC_Id);


                Response.Redirect("~/admin_configuration_classes.aspx");
            }




        }

        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
        {
            Grid1.PageIndex = e.NewPageIndex;
            LoadTeachingClassInform();

        }

        /*protected void search_btn_Click(object sender, EventArgs e)
        {

        }*/
    }
}